<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <input type="text" placeholder="请输入一个整数" v-model="num1">
    <input type="text" placeholder="请输入一个整数" v-model="num2">
    <input type="button" value="加" @click="f('加')">
    <input type="button" value="减" @click="f('减')">
    <input type="button" value="乘" @click="f('乘')">
    <input type="button" value="除" @click="f('除')">
    <h1>结果:{{info}}</h1>
</div>

<script src="js/vue.min.js"></script>
<script>
    let v = new Vue({
        el: "body>div",
        data: {
            num1: "",
            num2: "",
            info: ""
        },
        methods: {
            f(flag) {
                if (isNaN(v.num1) || isNaN(v.num2)) {
                    v.info = '输入的不是数字,请重新输入';
                    return;
                }
                switch (flag) {
                    case '加' :
                        v.info = (parseInt(v.num1) + parseInt(v.num2))
                        break;
                    case '减' :
                        v.info = (v.num1 - v.num2)
                        break;
                    case '乘' :
                        v.info = (v.num1 * v.num2)
                        break;
                    case '除' :
                        v.info = (v.num1 / v.num2)
                        break;
                }
            }
        }
    })
</script>
</body>
</html>